export VERSION=$1
echo 版本为$VERSION

export IMAGE_ID_BASE_TMP=$(docker images | grep base-tmp | awk '{print $3}')
export IMAGE_ID_MASTER_TMP=$(docker images | grep master-tmp | awk '{print $3}')
export IMAGE_ID_WORKER_TMP=$(docker images | grep worker-tmp | awk '{print $3}')
export IMAGE_ID_HISTORY_SERVER_TMP=$(docker images | grep history-server-tmp | awk '{print $3}')

if [ -z "$IMAGE_ID_BASE_TMP" ]; then
    echo "IMAGE_ID_BASE_TMP is empty"
else
    docker tag $IMAGE_ID_BASE_TMP registry-vpc.cn-hangzhou.aliyuncs.com/little_bee/spark-base:$VERSION
    docker tag $IMAGE_ID_BASE_TMP registry-vpc.cn-hangzhou.aliyuncs.com/little_bee/spark-base:latest
    docker tag $IMAGE_ID_BASE_TMP registry.cn-hangzhou.aliyuncs.com/little_bee/spark-base:$VERSION
    docker tag $IMAGE_ID_BASE_TMP registry.cn-hangzhou.aliyuncs.com/little_bee/spark-base:latest
    docker push registry-vpc.cn-hangzhou.aliyuncs.com/little_bee/spark-base:$VERSION
    docker push registry-vpc.cn-hangzhou.aliyuncs.com/little_bee/spark-base:latest
fi

if [ -z "$IMAGE_ID_MASTER_TMP" ]; then
    echo "IMAGE_ID_MASTER_TMP is empty"
else
    docker tag $IMAGE_ID_MASTER_TMP registry-vpc.cn-hangzhou.aliyuncs.com/little_bee/spark-master:$VERSION
    docker tag $IMAGE_ID_MASTER_TMP registry-vpc.cn-hangzhou.aliyuncs.com/little_bee/spark-master:latest
    docker tag $IMAGE_ID_MASTER_TMP registry.cn-hangzhou.aliyuncs.com/little_bee/spark-master:$VERSION
    docker tag $IMAGE_ID_MASTER_TMP registry.cn-hangzhou.aliyuncs.com/little_bee/spark-master:latest
    docker push registry-vpc.cn-hangzhou.aliyuncs.com/little_bee/spark-master:$VERSION
    docker push registry-vpc.cn-hangzhou.aliyuncs.com/little_bee/spark-master:latest
fi

if [ -z "$IMAGE_ID_WORKER_TMP" ]; then
    echo "IMAGE_ID_WORKER_TMP is empty"
else
    docker tag $IMAGE_ID_WORKER_TMP registry-vpc.cn-hangzhou.aliyuncs.com/little_bee/spark-worker:$VERSION
    docker tag $IMAGE_ID_WORKER_TMP registry-vpc.cn-hangzhou.aliyuncs.com/little_bee/spark-worker:latest
    docker tag $IMAGE_ID_WORKER_TMP registry.cn-hangzhou.aliyuncs.com/little_bee/spark-worker:$VERSION
    docker tag $IMAGE_ID_WORKER_TMP registry.cn-hangzhou.aliyuncs.com/little_bee/spark-worker:latest
    docker push registry-vpc.cn-hangzhou.aliyuncs.com/little_bee/spark-worker:$VERSION
    docker push registry-vpc.cn-hangzhou.aliyuncs.com/little_bee/spark-worker:latest
fi

if [ -z "$IMAGE_ID_HISTORY_SERVER_TMP" ]; then
    echo "IMAGE_ID_HISTORY_SERVER_TMP is empty"
else
    docker tag $IMAGE_ID_HISTORY_SERVER_TMP registry-vpc.cn-hangzhou.aliyuncs.com/little_bee/spark-history-server:$VERSION
    docker tag $IMAGE_ID_HISTORY_SERVER_TMP registry-vpc.cn-hangzhou.aliyuncs.com/little_bee/spark-history-server:latest
    docker tag $IMAGE_ID_HISTORY_SERVER_TMP registry.cn-hangzhou.aliyuncs.com/little_bee/spark-history-server:$VERSION
    docker tag $IMAGE_ID_HISTORY_SERVER_TMP registry.cn-hangzhou.aliyuncs.com/little_bee/spark-history-server:latest
    docker push registry-vpc.cn-hangzhou.aliyuncs.com/little_bee/spark-history-server:$VERSION
    docker push registry-vpc.cn-hangzhou.aliyuncs.com/little_bee/spark-history-server:latest
fi

